﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using QQZiCore.Mvc.Controllers;
using QQZiFramework;

namespace QQZiCore.SH3H.Api.Controllers
{
    /// <summary>
    /// 漏损相关
    /// </summary>
    public class LAMSController : BaseController
    {

        [NonAction]
        public override DBContext CreateDBContext()
        { 
            string oem = this.RouteData.Values["OEM"] as string;
            return CreateOEMContext(oem + "-LAMS");
        }
        /// <summary>
        /// 处理通过DoQuery查询的EntityName参数
        /// </summary>
        protected override string GetQueryEntityName()
        {
            string entityName = GetParamValue<string>("entityName");
            if (entityName.IndexOf(".") == -1)
            {
                entityName =string.Format("ApiDemo.Modals.LAMS.{0},ApiDemo", entityName);
            }
            else if (entityName.IndexOf(",") == -1)
            {
                entityName += ",QQZiCore.SH3H.Modals";
            }
            return entityName;
        }




        protected override void OnQuerying(QueryParam param, DBContext db)
        {
            base.OnQuerying(param, db);
            if (param.permission == "LAMS-WATER-USAGE")
            {
                // Hashtable ht = base.GetDBContextFormatSource();
                // string DATA_DATE = param.ClientWhere["DATA_DATE"];
                // ht.Add("DATA_DATE", DATA_DATE);
                // param.ClientWhere.Clear();

            }
        }



    }
}
